package com.lgc.javathread.threadLocalTest.test2;

/**
 * 一个线程，多个ThreadLocal的例子
 *
 * //***** ThreadLocalMap的key是ThreadLocal类的实例对象，value为用户的值，并不是网上大多数的例子key是线程的名字或者标识。
 */
public class Son2 implements Cloneable {
    public static void main(String[] args){
        Thread t = new Thread(new Runnable(){
            @Override
            public void run(){
                ThreadLocal<Son2> threadLocal1 = new ThreadLocal<>();
                threadLocal1.set(new Son2());
                System.out.println(threadLocal1.get());

                ThreadLocal<Son2> threadLocal2 = new ThreadLocal<>();
                threadLocal2.set(new Son2());
                System.out.println(threadLocal2.get());
            }});
        t.start();
    }
}
